package com.company.demo.factory_pattern;

import com.company.demo.TestInterface;

public class FactoryMethodTest implements TestInterface {
    @Override
    public void run() {

        System.out.println("工厂方法模式");
        Operater operater;
        operater = new FactoryAdd().createProduct();
        Calculator calculator = new Calculator();
        calculator.setOperaterNumber(1, 2);
        calculator.setOperater(operater);
        double result = calculator.getResult();

        System.out.println("1+2=" + result);

        operater = new FactoryPower().createProduct();
        calculator.setOperater(operater);
        result = calculator.getResult();

        System.out.println("1^2=" + result);

    }
}
